<!DOCTYPE html>
<html>
<head>
    <include file="public:meta"/>
    <link rel="stylesheet" href="../public/css/company.css">
    <qscms:load type="category"/>
</head>
<body>
    <include file="public:header"/>
    <include file="public:footer_min" />
    <script type="text/javascript">
        //调用微信JS api 支付
          function jsApiCall()
          {
            WeixinJSBridge.invoke(
              'getBrandWCPayRequest',
              {$jsApiParameters},
              function(res){
                WeixinJSBridge.log(res.err_msg);
                // console.log(res.err_msg);
                if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                    qsToast({type:1,context: "支付成功！"});
                    setTimeout(function(){
                        window.location.href="{:U('Company/allowance')}";
                    },2000);
                }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。 
                else if(res.err_msg == "get_brand_wcpay_request:cancel"){
                    qsToast({type:1,context: "支付失败！"});
                    setTimeout(function(){
                        window.history.go('-1');
                    },2000);
                }   
              }
            );
          }

          function callpay()
          {
            if (typeof WeixinJSBridge == "undefined"){
                if( document.addEventListener ){
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                }else if (document.attachEvent){
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            }else{
                jsApiCall();
            }
          }
        $(function(){
            callpay();
        });
    </script>
</body>
</html>